package com.example.tool.activtiy.recylerview;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.example.tool.R;
import com.example.tool.activtiy.base.BaseActivity;
import com.example.tool.adapter.GrideAdapter;
import com.example.tool.adapter.ShowAdapter;
import com.example.tool.adapter.base.decoration.GrideDecoration;
import com.example.tool.mvp.CommonPresent;
import com.example.tool.util.DebugLog;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created Date 2019/12/4.
 *
 * @author liangkun
 * ClassDescription：
 */
public class GrideRvActivity extends BaseActivity<CommonPresent> {
    @BindView(R.id.rv_home)
    protected RecyclerView recyclerView;
    @BindView(R.id.tv_title)
    protected TextView tvTitle;
    private List<String> mDatas;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_adapter;
    }

    @Override
    protected void initView() {
        tvTitle.setText("网格布局");
        GridLayoutManager layoutManager = new GridLayoutManager(this, 3);
        recyclerView.setLayoutManager(layoutManager);

        GrideDecoration grideDecoration = new GrideDecoration(mContext.getResources().getDimensionPixelOffset(R.dimen.sw_dp_7),
                mContext.getResources().getDimensionPixelOffset(R.dimen.sw_dp_3));
        recyclerView.addItemDecoration(grideDecoration);

        // 减掉RecyclerView父布局两侧padding和item的宽度，然后平分，默认每个item右侧会填充剩余空间
//        int spaceWidth = (getw -
//                (int) (getResources().getDimension(R.dimen.sw_dp_7) * 2) -
//                (int) (getResources().getDimension(R.dimen.sw_dp_7) * 3)) / (3 * (3 - 1));
//        guessRecyclerView.addItemDecoration(new SpaceItemDecoration(spaceWidth, column));

        mDatas = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            mDatas.add(String.valueOf(i));
        }
        GrideAdapter grideAdapter = new GrideAdapter(this, mDatas, R.layout.file_grid_item);
        recyclerView.setAdapter(grideAdapter);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected CommonPresent createPresenter() {
        return null;
    }
}
